home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_INT.ZIP / SPX_GUI.INT < prev    next >
Text File  |  1993-09-21  |  10KB  |  220 lines

  1. Unit spx_gui;
  2.  
  3. {$X+,O+ }
  4. { SPX Library Version 2.0  Copyright 1993 Scott D. Ramsay }
  5. { NOTE: Keystrokes does not work with keyboard interupt in spx_key enabled }
  6.  
  7. Interface
  8.  
  9. Uses crt,dos,spx_vga,spx_dos,spx_obj,spx_fnc,spx_txt,mouse;
  10.  
  11. const
  12.   id_button = 1;       { button id numbers }
  13.   id_string = 2;
  14.   id_check  = 3;
  15.   id_radio  = 4;
  16.   id_scroll = 5;
  17.   id_pbox   = 6;
  18.  
  19.  { system color index values }
  20.   sysc_black      = 0;                  { black }
  21.   sysc_background = 1;                  { background }
  22.   sysc_medbkgnd   = 2;                  { medium shade background }
  23.   sysc_darkbkgnd  = 3;                  { dark shade background }
  24.   sysc_text       = 4;                  { default text }
  25.   sysc_textshadow = 5;                  { default text shadow color }
  26.   sysc_highlite1  = 6;                  { highlight text 1 }
  27.   sysc_highlite2  = 7;                  { highlight text 2 }
  28.  
  29.   mLeftButton  = 1;    { button action values for the MMASK variable }
  30.   mRightButton = 2;
  31.   mBothButtons = 3;
  32.  
  33.   WinUpdate  : boolean = true; { FALSE - don't update save back on offwin call }
  34.   DiskVerify : boolean = true; { TRUE - Check within diskdo if file exist or can overwrite }
  35.  
  36. type
  37.   Tattr       = record
  38.                   x,y,w,h : integer;
  39.                 end;
  40.   Pbutton     = ^Tbutton;
  41.   Pobjlist    = ^Tobjlist;
  42.   itempos     = (center,top,left,bottom,right);
  43.   vcolortypes = array[0..7] of byte;
  44.   wcolortypes = array[0..7] of rgbtype;
  45.   Tproc_a     = procedure(p:pbutton);
  46.   Tproc_b     = procedure(p:pbutton;on:boolean);
  47.   Tbutton     = object(tobjs)
  48.                   idnum            : word;
  49.                   tch              : char;
  50.                   mmask            : byte;
  51.                   attr             : Tattr;
  52.                   title            : string;
  53.                   titlex,titley    : itempos;
  54.                   tfunct,
  55.                   visible,disabled : boolean;
  56.                   cdraw,caction    : Tproc_a;
  57.                   cnear            : Tproc_b;
  58.                   root             : Pobjlist;
  59.                   res1             : pointer;    { reserved for internal use }
  60.                   msg              : string;
  61.                   constructor init(x,y,w,h,idn:integer;ch:char;fnc:boolean;t:string);
  62.                   procedure drawitemobject;virtual;
  63.                   procedure nearitemobject(on:boolean);virtual;
  64.                   procedure actionitemobject;virtual;
  65.                   procedure showpress;virtual;
  66.                   procedure show(on:boolean);virtual;
  67.                   function ncheckhit(hx,hy,ohx,ohy:integer;item:pobjlist):boolean;virtual;
  68.                   destructor done;virtual;
  69.                 end;
  70.   Pstring     = ^Tstring;
  71.   Tstring     = object(Tbutton)
  72.                   esx,esy,epx,epy : integer;
  73.                   objectx,objecty : itempos;
  74.                   spaceok,upper,
  75.                   numonly         : boolean;
  76.                   tlenmax         : byte;
  77.                   tstr            : string;
  78.                   constructor init(x,y,w,h,idn:integer;ch:char;fnc:boolean;t,t2:string;tmax:byte);
  79.                   procedure drawitemobject;virtual;
  80.                   procedure showpress;virtual;
  81.                   procedure filename(px,py:integer;var fname:string);
  82.                 end;
  83.   Pcheck      = ^Tcheck;
  84.   Tcheck      = object(Tstring)
  85.                   tchk : boolean;
  86.                   constructor init(x,y,w,h,idn:integer;ch:char;fnc:boolean;t:string;chk:boolean);
  87.                   procedure drawitemobject;virtual;
  88.                   procedure show(on:boolean);virtual;
  89.                   procedure showpress;virtual;
  90.                   procedure actionitemobject;virtual;
  91.                 end;
  92.   Pradio      = ^Tradio;
  93.   Tradio      = object(Tcheck)
  94.                   group : integer;
  95.                   constructor init(x,y,w,h,idn,grp:integer;ch:char;fnc:boolean;t:string;chk:boolean);
  96.                   procedure drawitemobject;virtual;
  97.                   procedure show(on:boolean);virtual;
  98.                   procedure showpress;virtual;
  99.                   procedure actionitemobject;virtual;
  100.                 end;
  101.   Pscroll     = ^Tscroll;
  102.   Tscroll     = object(Tbutton)
  103.                   horz      : boolean;
  104.                   tx1,ty1,
  105.                   tx2,ty2,
  106.                   pvlu,siz,
  107.                   bmin,bmax,
  108.                   bpos,binc : integer;
  109.                   constructor init(x,y,w,h,idn,min,max,bi,bp:integer;hz:boolean);
  110.                   procedure showpress;virtual;
  111.                   procedure drawitemobject;virtual;
  112.                   procedure redrawscroll;
  113.                   function porp(vlu,max,min,p1,p2,wd:integer):integer;
  114.                 end;
  115.   Ppbox       = ^Tpbox;
  116.   Tpbox       = object(Tbutton)
  117.                   objs  : Pobjlist;
  118.                   sh,st : plist;
  119.                   lhstr : string;
  120.                   lhdat : longint;
  121.                   items : integer;
  122.                   constructor init(x,y,w,i,idn:integer;t:string);
  123.                   function ncheckhit(hx,hy,ohx,ohy:integer;item:Pobjlist):boolean;virtual;
  124.                   procedure drawitemobject;virtual;
  125.                   procedure additem(s:string;d:longint;draw:boolean);virtual;
  126.                   function delitem(s:string;d:longint;draw:boolean):boolean;virtual;
  127.                   function getcount:integer;virtual;
  128.                   procedure show(on:boolean);virtual;
  129.                   destructor done;virtual;
  130.                 end;
  131.   Pkey_io     = ^Tkey_io;
  132.   Tkey_io     = object
  133.                   funct : boolean;      { TRUE - extended character }
  134.                   ch    : char;         { character pressed }
  135.                   constructor init(h:char;f:boolean);
  136.                   procedure inkey; virtual;
  137.                   function apress : boolean; virtual;
  138.                   procedure clearbuffer; virtual;
  139.                   destructor done; virtual;
  140.                 end;
  141.   Pmouse_io   = ^Tmouse_io;
  142.   Tmouse_io   = object(Tkey_io)
  143.                   mpx,mpy,                { mouse position }
  144.                   opx,opy,                { mouse old position }
  145.                   mop,lmop,               { mouse button, old button }
  146.                   lx,ly,x,y : integer;    { mouse motion variables }
  147.                   constructor init(h:char;f:boolean;sx,sy,m:integer);
  148.                   procedure inkey; virtual;
  149.                   function apress : boolean; virtual;
  150.                   function mousepressed : boolean; virtual;
  151.                   procedure clearbuffer; virtual;
  152.                   destructor done; virtual;
  153.                 end;
  154.   Tobjlist    = object
  155.                   head,tail : plist;
  156.                   io        : Pmouse_io;
  157.                   focus     : pbutton;
  158.                   gmsg       : string;
  159.                   orange     : pbutton;
  160.                   constructor init;
  161.                   procedure inkey;virtual;
  162.                   procedure clearbuffer;virtual;
  163.                   function addobject(item:Pbutton):Pbutton;virtual;
  164.                   function checkpress(var p:pbutton):integer;virtual;
  165.                   function retobject(hnd:integer):pbutton;virtual;
  166.                   procedure showall;virtual;
  167.                   destructor done;virtual;
  168.                  private
  169.                   rmop,
  170.                   rmx,rmy,
  171.                   romx,romy : integer;
  172.                 end;
  173.  
  174. const
  175.   cl            : vcolortypes = (0,23,31,8,15,8,9,28); { System colors }
  176.  
  177.   defaultcolors : wcolortypes =                        { System want colors }
  178.                  ((red:00;green:00;blue:00),           { background - black }
  179.                   (red:35;green:35;blue:35),           { object background  }
  180.                   (red:49;green:49;blue:48),           { Medium Shade       }
  181.                   (red:21;green:21;blue:21),           { Dark Shade         }
  182.                   (red:63;green:63;blue:63),           { Text, Light Shade  }
  183.                   (red:21;green:21;blue:21),           { Generic medium     }
  184.                   (red:21;green:21;blue:63),           { Highlite 1         }
  185.                   (red:53;green:14;blue:14));          { Highlite 2         }
  186.   burntsienna   : wcolortypes =
  187.                  ((red:00;green:00;blue:00),
  188.                   (red:48;green:28;blue:00),
  189.                   (red:54;green:35;blue:00),
  190.                   (red:35;green:15;blue:00),
  191.                   (red:63;green:63;blue:63),
  192.                   (red:35;green:15;blue:00),
  193.                   (red:58;green:57;blue:18),
  194.                   (red:00;green:63;blue:45));
  195.  
  196. var
  197.   drives     : string[26] ;
  198.   driveset   : set of 'A'..'Z';
  199.   gx,gy      : integer;
  200.   menucolors : wcolortypes;
  201.  
  202. function strlen(s:string):word;
  203. procedure textpos(title:string;tx1,ty1,tx2,ty2:integer;txpos,typos:itempos;var ux,uy:integer);
  204. procedure pointpos(tx1,ty1,tx2,ty2:integer;txpos,typos:itempos;var ux,uy:integer);
  205. procedure drawstring(x,y:integer;s:string;c1,c2:byte);
  206. procedure vgaborder(x1,y1,x2,y2:integer;border:boolean);
  207. procedure vgainvr(x1,y1,x2,y2:integer;border:boolean);
  208. procedure vgarect(x1,y1,x2,y2:integer);
  209. procedure vgabox(x1,y1,x2,y2:integer);
  210. function onwin(x,y,w,h:integer;border:boolean):boolean;
  211. procedure offwin;
  212. procedure message(s:string;wait:boolean);
  213. function yes(msg:string):boolean;
  214. function diskdo(x,y:integer;fpath,mask,title:string;loading:boolean):string;
  215. procedure finddrives;
  216. function writeable(pth:string):boolean;
  217. procedure adjustmenupalette; { changes menu index colors (CL) to match }
  218.                              { the (menucolor) colors                  }
  219.  
  220.